home *** CD-ROM | disk | FTP | other *** search
- 100 rem ** A Demo of 3 sprites bouncing around over a changing background **
- 110 rem
- 120 dim x(10),y(10),dx(10),dy(10)
- 150 gosub 340
- 155 print " boxes and sprites ";time$
- 160 for i2 = 1 to 600000
- 170 x1 = x(4)+rnd(320)
- 180 x2 = x(4)+rnd(320)
- 190 if (x1 > x2) then 170
- 200 y1 = y(4)+rnd(240)
- 210 y2 = y(4)+rnd(240)
- 220 if (y1 > y2) then 200
- 230 m = rnd(32)
- 240 j = rnd(100) : j2 = rnd(100) : j3 = rnd(100)
- 250 graphics color j,j2,j3
- 260 if rnd(10) > 6 then goto 290
- 270 graphics fillrect x1,y1,x2,y2,m : graphics rect x1,y1,x2,y2
- 280 goto 300
- 290 graphics filloval x1,y1,x2,y2,m : graphics oval x1,y1,x2,y2
- 300 if i2 and 1 then gosub 450
- 310 graphics(0) : rem *** wait for refresh ***
- 320 next i2
- 330 end
- 340 rem *** display an initial background ***
- 350 cls
- 360 graphics 0
- 370 for i = 1 to 20
- 380 moveto 10,10*i : lineto 200,10*i
- 390 moveto 10*i,10 : lineto 10*i,200
- 400 next i
- 410 t = timer
- 420 moveto 210,100 : graphics drawtext "Demo"
- 430 for i = 1 to 10 : x(i) = 100+i : y(i) = 100-i : next i
- 440 return
- 450 rem *** Display and Move Sprites ***
- 460 sprite 1 x(1),y(1),131
- 470 sprite 2 x(2),y(2),128
- 480 sprite 3 x(3),y(3),129
- 485 graphics window -1,-1,x(4),y(4),2
- 490 for i = 1 to 4
- 500 dx(i) = dx(i)-1+rnd(3)
- 510 if abs(dx(i)) > 10 then dx(i) = dx(i)/2
- 520 x(i) = x(i)+dx(i)
- 530 if x(i) > 310 or x(i) < 8
- 532 dx(i) = sgn(100-x(i))*abs(dx(i)) : x(i) = x(i)+2*dx(i)
- 534 if i < 4 then sound 400,0.05,40
- 536 endif
- 540 dy(i) = dy(i)-1+rnd(3)
- 550 if abs(dy(i)) > 10 then dy(i) = dy(i)/2
- 560 y(i) = y(i)+dy(i)
- 570 if y(i) > 220 or y(i) < 8
- 572 dy(i) = sgn(100-y(i))*abs(dy(i)) : y(i) = y(i)+2*dy(i)
- 574 if i < 4 then sound 400,0.05,40
- 576 endif
- 580 next i
- 582 if x(4) > graphics(-38)-320 then x(4) = graphics(-38)-322
- 584 if y(4) > graphics(-39)-240 then y(4) = graphics(-39)-242
- 590 n = n+1
- 600 if timer-t > 10 then print (n-n0)/(timer-t);" fps",fre : t = timer : n0 = n
- 610 return
- 620 end
-